package com.yangming.springboot.deepin.playTest;

import java.util.concurrent.TimeUnit;

/**
 * @创建人 ym
 * @创建时间 2021/4/8 0008
 * @描述
 **/
public class Profiler {

    private static final ThreadLocal<Long> TIME_THREADLOCAL = new ThreadLocal<Long>();

    protected Long initialValue(){
        return System.currentTimeMillis();
    };

    public static final void begin(){
        TIME_THREADLOCAL.set(System.currentTimeMillis());
    }

    public static final long end(){
        return System.currentTimeMillis() - TIME_THREADLOCAL.get();
    }

    public static void main(String[] args) throws Exception{
        Profiler.begin();
        TimeUnit.SECONDS.sleep(1);
        System.out.println(Profiler.end() + "mills");
        System.out.println(System.currentTimeMillis());
    }

}
